#include "Common.hpp"
#include "TcpServer.hpp"

std::string defaultHandler(const std::string& message, InetAddr& addr){
    std::string s = addr.StringAddr() + "test, ";
    s += message;
    return s;
}

void Usage(std::string proc){
    std::cerr << "Usage: " << proc << "port"; 
}

int main(int argc, char* argv[]){
    if(argc != 2){
        Usage(argv[0]);
        exit(USAGE_ERR);
    }

    uint16_t port = std::stoi(argv[1]);
    Enable_Console_Log_Strategy();

    std::unique_ptr<TcpServer> tser = std::make_unique<TcpServer>(defaultHandler, port);
    tser->Init();
    tser->Run();

    return 0;
}
